//
//  WENNavController.m
//  百思不得姐--001
//
//  Created by wen on 2018/10/10.
//  Copyright © 2018 wen. All rights reserved.
//

#import "WENNavController.h"

@interface WENNavController ()

@end

@implementation WENNavController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

//当第一次来到这个类的时候会调用一次，今后不会再来了
+(void)initialize {
    //指定类导航栏设置背景
    UINavigationBar *bar = [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class], [self class]]];
    
    //设置导航栏背景图片
    [bar setBackgroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite"] forBarMetrics:UIBarMetricsDefault];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    //自定义左上角返回按钮
    //需要判断：如果是栈底，我们不更换左上角按钮
    if (self.childViewControllers.count > 0) {
       //想要隐藏，必须在push之前设置
        viewController.hidesBottomBarWhenPushed = YES;
        
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem wen_backItemWithImageName:@"navigationButtonReturn" title:@"返回" target:self action:@selector(back)];
    }
    
    // 调用父类的方法
    [super pushViewController:viewController animated:animated];
}

- (void)back {
    [self popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
